﻿using MdxLib.Model;
using MdxLib.ModelFormats;
using Microsoft.Xna.Framework.Content.Pipeline;
using System.IO;


// FileDescription: This file is to import the .mdx file and translate them into c# class
namespace XNADota.ContentPipeline.MDX
{
    [ContentImporter(".mdx", DefaultProcessor = "MdxProcessor", DisplayName = "MDX Importer")]
    class MdxImporter : ContentImporter<MdxLib.Model.CModel>
    {
        public override CModel Import(string filename, ContentImporterContext context)
        {
            var model = new MdxLib.Model.CModel();

            using (var Stream = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read))
            {
                var ModelFormat = new MdxLib.ModelFormats.CMdx();
                ModelFormat.Load(filename, Stream, model);
            }

            return model;
        }
    }

    [ContentImporter(".mdl", DefaultProcessor = "MdlProcessor", DisplayName = "MDL Importer")]
    class MdlImporter : ContentImporter<MdxLib.Model.CModel>
    {
        public override CModel Import(string filename, ContentImporterContext context)
        {
            var model = new MdxLib.Model.CModel();

            using (var Stream = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read))
            {
                var ModelFormat = new MdxLib.ModelFormats.CMdl();
                ModelFormat.Load(filename, Stream, model);
            }

            return model;
        }
    }
}
